package com.hshit.downloader.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hshit.downloader.MainActivity;

public abstract class BaseFragment extends LayoutTab {
	public static final String MP3_FRAGMENT 			= Mp3Fragment.class.getSimpleName();
	public static final String DOWNLOAD_FRAGMENT 		= DownloadStatusFragment.class.getSimpleName();
	
	public static final int TAB_MP3 					= 0;
	public static final int TAB_DOWNLOAD 				= 1;
	
	protected MainActivity mCallback;
	
	public int mContentLayoutId;
	
	protected boolean isViewCreated = false; 
	
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            mCallback = (MainActivity) activity;

        } catch (ClassCastException e) {
            e.printStackTrace();
        }
    }
	
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        setContentLayoutId();
        View view = inflater.inflate(mContentLayoutId, container, false);
        onAfterView(view);
        return view;
    }
    
    /**
     * After layout be inflated we will do something else
     */
    public abstract  void onAfterView (View view);
    
    /**
     * Set Fragment's layout id on mContentLayoutId
     */
    public abstract void setContentLayoutId();
    
    public void setViewCreated(boolean isViewCreated) {
    	this.isViewCreated = isViewCreated;
    }
    
    public boolean getViewCreated() {
    	return this.isViewCreated;
    }
	
}
